package com.frame.auth.security.service;

import org.springframework.security.oauth2.common.util.RandomValueStringGenerator;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.code.InMemoryAuthorizationCodeServices;

/**
 * @auther zhangwj
 * @date 2021/3/24 下午2:14
 */
public class AuthCodeInMemoryService extends InMemoryAuthorizationCodeServices {

    private RandomValueStringGenerator generator = new RandomValueStringGenerator(12);

    @Override
    public String createAuthorizationCode(OAuth2Authentication authentication) {
        String code = generator.generate();
        store(code, authentication);
        return code;
    }
}
